from django.db import models

class FlowNode(models.Model):
    node_id = models.CharField(max_length=255, unique=True)
    type = models.CharField(max_length=50)
    position_x = models.FloatField()
    position_y = models.FloatField()
    data = models.JSONField()

    def __str__(self):
        return f"{self.type} Node ({self.node_id})"

class FlowEdge(models.Model):
    edge_id = models.CharField(max_length=255, unique=True)
    source = models.CharField(max_length=255)
    target = models.CharField(max_length=255)
    source_handle = models.CharField(max_length=50)
    target_handle = models.CharField(max_length=50)

    def __str__(self):
        return f"Edge {self.source}->{self.target}"